<template>
  <div v-show="isCarListShow" class="car-container">
    <!-- 遮罩层 -->
    <div class="mask" @click="hideCarList"></div>
    <!-- list -->
    <div class="foot-car-list">
      <!-- 商品信息组件 -->
      <h3>已选商品</h3>
      <ul class="selected-list">
        <!-- 商品信息组件 -->
          <product-info
            :height="'mini-height'"
            v-for="product in selectedProducts"
            :key="product.id"
            :proInfo="product"
          ></product-info>
      </ul>
    </div>
  </div>
</template>

<script>
import ProductInfo from "../common/components/ProductInfo.vue";

export default {
  components: {
    ProductInfo,
  },
  data() {
    return {
      isCarListShow: false, // 购物车列表是否展示
    }
  },
  computed: {
    selectedProducts() {
      return this.$store.state.selectedProducts;
    }
  },
  methods: {
    hideCarList() {
      this.isCarListShow = false;
    },
    showCarList() {
      this.isCarListShow = true;
    }
  }
};
</script>

<style scoped>
.car-container {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.car-container .mask {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}
.foot-car-list {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 4rem;
  border-top-left-radius: 0.08rem;
  border-top-right-radius: 0.08rem;
  background-color: #fff;
  overflow-y: auto;
}
.selected-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  padding-bottom: 0.7rem;
  overflow-y: auto;
}
.foot-car-list h3 {
  padding: 0 0.1rem;
  color: #666666;
}
</style>
